import java.io.*;
import java.text.DecimalFormat;
import java.util.*;
import static java.lang.Integer.*;
import static java.lang.Math.*;
import static java.lang.Double.*;
import static java.lang.Long.*;
public class Util
{
	private static final DecimalFormat FORMATTER = new DecimalFormat("0.0");
	public static String toString( final BitSet b , final int size)
	{
		StringBuilder sb = new StringBuilder();
		for (int i = 0; i < size; i++)
			sb.append( (b.get(i) )? "1" : "0" );
		return new StringBuilder( sb.toString() ).reverse().toString();
	}
	public static double[][] readMatrix( final int rows , final int cols , final String fileName )throws Exception	
	{
		double ans[][] = new double[rows][cols];
		Scanner sn = new Scanner( new FileReader( new File(fileName)));
		for (int i = 0; i < rows; i++)
			for (int j = 0; j < cols; j++)
				ans[i][j] = sn.nextDouble();
		
		return ans;
	}
	public static void printMatrix(double[][] m) {
		int N = m.length;
		int M = m[0].length;
		for (int i = 0; i < N; i++)
		{
			for (int j = 0; j < M; j++)
				System.out.print(" "+(m[i][j]));
			System.out.println();
		}			
	}
	public static String format( final double num )
	{
		return FORMATTER.format(num);
	}
	public static String toString(double[] a) {
		StringBuilder sb = new StringBuilder();
		for (double num : a)
			sb.append(format(num)+" ");		
		return sb.toString().trim();
	}
	public static String format(double num, int presition)
	{
		String s = "0.0";
		while( s.length() < presition + 2 )
			s += "0";
		return new DecimalFormat(s).format(num);
	}
}
